class Animal{
    String name;
    int age;
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public void eat(){
        System.out.println(name+"吃饭....");
    }
}
class Dog extends Animal{
    public Dog(String name,int age){
        super(name,age);
    }
    @Override
    public void eat() {
        System.out.println(name + "正在吃狗粮.....");
    }
    public void bark(){
        System.out.println(name+"正在旺旺叫.....");
    }
}

class Cat extends Animal{
    public Cat(String name, int age) {
        super(name, age);
    }
    @Override
    public void eat() {
        System.out.println(name+"正在吃猫粮......");;
    }
    public void mew(){
        System.out.println(name+"正在喵喵叫.....");
    }
}

//*******************************************
public class test {
    static void eat1(Animal A){
        A.eat();
    }
    public static void main1(String[] args) {
        Dog dog = new Dog("冲冲",18);
        Cat cat = new Cat("JAVA",90);
        //eat(dog);//这就是传参实现向上转型
        //eat(cat);
    }
    public static void main2(String[] args) {
        Dog dog = new Dog("冲冲",18);
        Animal animal1 = dog;//这就属于直接赋值
        animal1.eat();
        Cat cat = new Cat("JAVA",90);
        Animal animal2 = cat;
        animal2.eat();
    }

    Animal eat(){
        return new Cat("小猫",2);
    }
    public static void main(String[] args) {
        Cat cat = new Cat("JAVA",90);
        cat.eat();
    }
}


